UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'aT5ENQX7S8CS+sL3h6T9Tpj1OTkvN7W3dW53Vegl5DA=' 
WHERE 
  key_id = 'ba1031f68c6452ef386258de8b3a70c831d9a0b55b16302209a32d6e37f34aa3' 
  AND (
    token = 'aT5ENQX7S8CS+sL3h6T9Tpj1OTkvN7W3dW53Vegl5DA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00019