UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'uqgOVTh7T1xDMlvCV0Qh0hHcqdJsVHneffKrfTyg4Wc=' 
WHERE 
  key_id = '959a8cee2a9dbd0628f626912f25855a2e1df8e33ced43430319eec62ada9674' 
  AND (
    token = 'uqgOVTh7T1xDMlvCV0Qh0hHcqdJsVHneffKrfTyg4Wc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024