UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'HQYXsL9UpKRBdTnTog2c/klakLpAN43x+UVfX5rQRts=' 
WHERE 
  key_id = '45cf0d4c7288e8fe6792ca27d68e31c35096def1649467e06913bcfc1b07bed9' 
  AND (
    token = 'HQYXsL9UpKRBdTnTog2c/klakLpAN43x+UVfX5rQRts=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031